package com.moorecat;

import java.util.ArrayList;
import java.util.List;

import android.app.Application;
import android.content.res.Resources;
import android.graphics.Bitmap;

import com.moorecat.app.provider.DBHelper;
import com.moorecat.bean.User;
import com.moorecat.utils.UtilTools;
import com.moorecat.utils.ui.ImageUtils;

/**
 * 类说明
 * 
 * @author pengfei.xu
 * @version V1.0 创建时间：2011-4-28 下午05:31:29
 */
public class MooerApplication extends Application {

	private User user;

	private double latitude;

	private double longitude;

	private String address = "";

	private boolean isLoggedin;

	private Bitmap shopListDefaultIcon;

	private Bitmap avatarIcon;

	private Bitmap activityIcon;

	private DBHelper dbHelper;

	/*
	 * 商家一级分类
	 */
	private List<String[]> businessTypes = new ArrayList<String[]>();

	/*
	 * 商家二级分类
	 */
	private List<String[]> businessTypes2 = new ArrayList<String[]>();

	@Override
	public void onCreate() {
		super.onCreate();
		shopListDefaultIcon = ImageUtils.drawableToBitmap(getResources()
				.getDrawable(R.drawable.m_seller_pic));
		avatarIcon = ImageUtils.drawableToBitmap(getResources().getDrawable(
				R.drawable.avatar_pic_x));
		activityIcon = ImageUtils.drawableToBitmap(getResources().getDrawable(
				R.drawable.m_activity_pic_x));
		dbHelper = new DBHelper(this);
		initBusinessType();
	}

	private void initBusinessType() {
		Resources resources = getResources();
		businessTypes.add(resources.getStringArray(R.array.meishi));
		businessTypes.add(resources.getStringArray(R.array.liren));
		businessTypes.add(resources.getStringArray(R.array.huajia));
		businessTypes.add(resources.getStringArray(R.array.qinzi));
		businessTypes.add(resources.getStringArray(R.array.jianshen));
		businessTypes.add(resources.getStringArray(R.array.peixun));
		businessTypes.add(resources.getStringArray(R.array.xiuxianyule));
		businessTypes.add(resources.getStringArray(R.array.gouwu));
		businessTypes.add(resources.getStringArray(R.array.jiudian));
		businessTypes.add(resources.getStringArray(R.array.shenghuofuwu));

		businessTypes2.add(resources.getStringArray(R.array.meishi_position));
		businessTypes2.add(resources.getStringArray(R.array.liren_position));
		businessTypes2.add(resources.getStringArray(R.array.huajia_position));
		businessTypes2.add(resources.getStringArray(R.array.qinzi_position));
		businessTypes2.add(resources.getStringArray(R.array.jianshen_position));
		businessTypes2.add(resources.getStringArray(R.array.peixun_position));
		businessTypes2.add(resources
				.getStringArray(R.array.xiuxianyule_position));
		businessTypes2.add(resources.getStringArray(R.array.gouwu_position));
		businessTypes2.add(resources.getStringArray(R.array.jiudian_position));
		businessTypes2.add(resources
				.getStringArray(R.array.shenghuofuwu_position));
	}

	public Bitmap getShopListDefaultIcon() {
		return shopListDefaultIcon;
	}

	public void setShopListDefaultIcon(Bitmap shopListDefaultIcon) {
		this.shopListDefaultIcon = shopListDefaultIcon;
	}

	public double getLatitude() {
		return latitude;
	}

	public void setLatitude(double latitude) {
		this.latitude = UtilTools.round(latitude, 5);
	}

	public double getLongitude() {
		return longitude;
	}

	public void setLongitude(double longitude) {
		this.longitude = UtilTools.round(longitude, 5);
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public boolean isLoggedin() {
		return isLoggedin;
	}

	public void setLoggedin(boolean isLoggedin) {
		this.isLoggedin = isLoggedin;
	}

	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * @param user
	 *            the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}

	public DBHelper getDbHelper() {
		return dbHelper;
	}

	public void setDbHelper(DBHelper dbHelper) {
		this.dbHelper = dbHelper;
	}

	public Bitmap getAvatarIcon() {
		return avatarIcon;
	}

	public void setAvatarIcon(Bitmap avatarIcon) {
		this.avatarIcon = avatarIcon;
	}

	public Bitmap getActivityIcon() {
		return activityIcon;
	}

	public void setActivityIcon(Bitmap activityIcon) {
		this.activityIcon = activityIcon;
	}

	public List<String[]> getBusinessTypes() {
		return businessTypes;
	}

	public void setBusinessTypes(List<String[]> businessTypes) {
		this.businessTypes = businessTypes;
	}

	public List<String[]> getBusinessTypes2() {
		return businessTypes2;
	}

	public void setBusinessTypes2(List<String[]> businessTypes2) {
		this.businessTypes2 = businessTypes2;
	}

}